<?PHP
function do_shift($group, $day, $shift) {
		$s= "<td class=\"shift3\" rowspan=\"3\">".
				"<a id=\"shiftlink\" href=\"editMasterSchedule.php?group=".
				$group."&day=".$day."&shift=".$shift."\">".
				get_people_for_shift($group,$day,$shift).
			"</td>";
		return $s;
	}
	function do_shift_4($group, $day, $shift) {
		$s= "<td class=\"shift4\" rowspan=\"4\">";
		$s=$s."<a id=\"shiftlink\" href=\"editMasterSchedule.php?group=".$group."&day=".$day."&shift=".$shift."\">";
		$s=$s.get_people_for_shift($group,$day,$shift);
		$s=$s."</td>";

		return $s;
	}
	function show_wknd_schedule($group) {
		echo ("<table id=\"calendar_wknd\" align=\"center\"><tr><td colspan=\"3\" align=\"center\" class=\"weekname\">Weekend Group ".$group."</td></tr>
				<tr><td bgcolor=\"#7991B1\"></td><td class=\"dow\">&nbsp;Saturday</td>
				<td class=\"dow\">&nbsp;Sunday</td></tr>");

				echo ("<tr><td class=\"hour\">9am</td>
				<td colspan=\"1\" rowspan=\"1\" bgcolor=\"lightgray\">&nbsp;</td>"

				.do_shift("Wkd", "Sun".$group,"9-12").

				"</tr><tr><td class=\"hour\">10am</td>"
				.do_shift("Wkd", "Sat".$group,"10-13").
				"</tr><tr><td class=\"hour\">11am</td></tr>
				<tr><td class=\"hour\">12pm</td>
				<td colspan=\"1\" rowspan=\"2\" bgcolor=\"lightgray\">&nbsp;</td></tr>
				</tr><tr><td class=\"hour\">1pm</td>"
				.do_shift("Wkd", "Sat".$group,"13-16").
				"</tr><tr><td class=\"hour\">2pm</td>"
				.do_shift("Wkd", "Sun".$group,"14-17").
				"</tr><tr><td class=\"hour\">3pm</td>
				</tr><tr><td class=\"hour\">4pm</td>
				<td colspan=\"1\" rowspan=\"5\" bgcolor=\"lightgray\">&nbsp;</td>
				</tr><tr><td class=\"hour\">5pm</td>"
				.do_shift_4("Wkd","Sun".$group,"17-21").
				"</tr><tr><td class=\"hour\">6pm</td>
				</tr><tr><td class=\"hour\">7pm</td></tr>
				<tr><td class=\"hour\">8pm</td></tr>");
		echo ("</table>");
	}

	function get_people_for_shift($group,$day,$shift) {
		$people=get_persons($group,$day,$shift);
		$slots=get_total_slots($group,$day,$shift);
		if(!$people[0])
			array_shift($people);
		$p="<br>";
		for($i=0;$i<count($people);++$i) {
			if (is_array($people[$i]))
			   $p = $p."&nbsp;".$people[$i]['first_name']." ".$people[$i]['last_name']."<br>";
			else
			   $p = $p."&nbsp;".$people[$i]."<br>";
		}
		if($slots-count($people)>0)
			$p=$p."&nbsp;<b>Vacancies (".($slots-count($people)).")</b><br>";
		return substr($p,0,strlen($p)-4) ;
	}
?>